package top.kaoshanji.p2ch18a;

import top.kaoshanji.p2ch18a.support.DelayTask;

import java.util.Timer;

/**
 * 代码清单-p2ch18a-519页a：Timer基本示例
 * @see DelayTask
 * author kaoshanji
 * ^_^
 * create time 2025/2/27 17:02
 */
public class BasicTimer {


    public static void main(String[] args) throws InterruptedException {

        Timer timer = new Timer();
        timer.schedule(new DelayTask(), 1000); // 一秒钟后执行

        Thread.sleep(2000);

        timer.cancel(); // 取消所有定时任务
    }

}
